'''
Created on Nov 3, 2011

@author: hp
'''

def run(fname):
    
    fin = open(fname, 'r')
    
    correct = 0
    incorrect = 0
    
    for line in fin.read().split('\n'):
        if len(line) == 0:
            continue
        tok = line.split('\t')
        print tok
        gold = tok[0]
        pred = tok[1]
        
        if gold == pred:
            correct = correct + 1
        else:
            incorrect = incorrect + 1
    
    P = (correct * 1.0) / (correct + incorrect)
    print "Precision = %.2f" % (P) 

if __name__ == "__main__":
    run('/home/hp/Downloads/for-octavian-3-3-11/test-d-100-w-1-k-combo-s-ova.out')
    #avgP = 0.88